<?php

class StaffTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\Staff\StaffClass();
		$class['account'] = $this->testStr();
		$class['pwd'] = $this->testStr();
		$class['name'] = $this->testStr();
		$class['tel'] = $this->testStr();
		$class['email'] = $this->testStr();
		$class['admin_id'] = $this->testNum();
		$class['enterprise_role_id'] = $this->testNum();
		$class['country'] = $this->testNum();
		$class['province'] = $this->testNum();
		$class['city'] = $this->testNum();
		$class['area'] = $this->testNum();
		$class['address'] = $this->testStr();
		$class['type'] = $this->testNum();
		$class['remark'] = $this->testStr();
		$class['is_use'] = $this->testNum();


        $class->insert();
        $result_class = new \Orm\Staff\StaffClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['account'],$result_class['account']);
		$this->assertEquals($class['pwd'],$result_class['pwd']);
		$this->assertEquals($class['name'],$result_class['name']);
		$this->assertEquals($class['tel'],$result_class['tel']);
		$this->assertEquals($class['email'],$result_class['email']);
		$this->assertEquals($class['admin_id'],$result_class['admin_id']);
		$this->assertEquals($class['enterprise_role_id'],$result_class['enterprise_role_id']);
		$this->assertEquals($class['country'],$result_class['country']);
		$this->assertEquals($class['province'],$result_class['province']);
		$this->assertEquals($class['city'],$result_class['city']);
		$this->assertEquals($class['area'],$result_class['area']);
		$this->assertEquals($class['address'],$result_class['address']);
		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['remark'],$result_class['remark']);
		$this->assertEquals($class['is_use'],$result_class['is_use']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['account'] = $this->testStr();
		$class['pwd'] = $this->testStr();
		$class['name'] = $this->testStr();
		$class['tel'] = $this->testStr();
		$class['email'] = $this->testStr();
		$class['admin_id'] = $this->testNum();
		$class['enterprise_role_id'] = $this->testNum();
		$class['country'] = $this->testNum();
		$class['province'] = $this->testNum();
		$class['city'] = $this->testNum();
		$class['area'] = $this->testNum();
		$class['address'] = $this->testStr();
		$class['type'] = $this->testNum();
		$class['remark'] = $this->testStr();
		$class['is_use'] = $this->testNum();


        $class->update();
        $result_class = new \Orm\Staff\StaffClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['account'],$result_class['account']);
		$this->assertEquals($class['pwd'],$result_class['pwd']);
		$this->assertEquals($class['name'],$result_class['name']);
		$this->assertEquals($class['tel'],$result_class['tel']);
		$this->assertEquals($class['email'],$result_class['email']);
		$this->assertEquals($class['admin_id'],$result_class['admin_id']);
		$this->assertEquals($class['enterprise_role_id'],$result_class['enterprise_role_id']);
		$this->assertEquals($class['country'],$result_class['country']);
		$this->assertEquals($class['province'],$result_class['province']);
		$this->assertEquals($class['city'],$result_class['city']);
		$this->assertEquals($class['area'],$result_class['area']);
		$this->assertEquals($class['address'],$result_class['address']);
		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['remark'],$result_class['remark']);
		$this->assertEquals($class['is_use'],$result_class['is_use']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\Staff\StaffClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}